#!/bin/bash

NAME=nginx-server
PORT=8080
TAG=latest

while getopts "n:p:t:" opt; do
  case $opt in
    n)
        NAME=$OPTARG
        ;;
    p)
        PORT=$OPTARG
        ;;
    t)
        TAG=$OPTARG
        ;;
    \?)
        echo "invalid arg"
        exit 1
        ;;
  esac
done

docker run \
--restart always \
--name ${NAME} \
-p ${PORT}:80 \
-v ${PWD}/logs:/var/log/nginx \
-d \
nginx:${TAG}

# docker run \
# --restart always \
# --name ${NAME} \
# -p 18080:8080 \
# -p 18081:8081 \
# -v ${PWD}/conf:/etc/nginx/conf.d \
# -v ${PWD}/html:/usr/share/nginx/html:ro \
# -v ${PWD}/logs:/var/log/nginx \
# -v ~/Downloads:/home \
# -d \
# nginx:${TAG}